//
//  CZRootTool.m
//  OCKSFWeibo
//
//  Created by 盛 发 况 on 16/4/27.
//  Copyright © 2016年 盛 发 况. All rights reserved.
//

#import "CZRootTool.h"
#import "CZTabBarController.h"
#import "CZNewFeatureController.h"
#define CZVersionKey  @"Bundle version"

@implementation CZRootTool
/**
 *  选择根控制器
 */
+ (void)chooseRootViewController:(UIWindow *)window {
    
    // 1.获取当前的版本号
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
    // 2.获取上一次的版本号
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults]objectForKey:CZVersionKey];
    
    if ([currentVersion isEqualToString:lastVersion]) {
        CZTabBarController *tabBarVc = [[CZTabBarController alloc] init];
        window.rootViewController = tabBarVc;
        
    } else {
        CZNewFeatureController *newFeatureVC = [[CZNewFeatureController alloc] init];
        window.rootViewController = newFeatureVC;
        
        [[NSUserDefaults standardUserDefaults]setObject:currentVersion forKey:CZVersionKey];
        
    }
    
}
@end


